package com.example.city_home_app.RecyclerViewAdapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.city_home_app.Bean.Down_PostReply;
import com.example.city_home_app.Bean.PostContent;
import com.example.city_home_app.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class Adapter_PostReply extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context;
    private List<Down_PostReply> list;

    public Adapter_PostReply(Context context) {
        this.context = context;
    }

    public void setList(List<Down_PostReply> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(context).inflate(R.layout.recitem_post_reply, parent, false);
        Adapter_PostReply.ViewHolder viewHolder = new Adapter_PostReply.ViewHolder(itemView);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        final Down_PostReply bean = list.get(position);
        if(bean == null){
            return;
        }
        final Adapter_PostReply.ViewHolder viewHolder = (Adapter_PostReply.ViewHolder) holder;
        viewHolder.tvRecitemPostreplyContent.setText(bean.getUser_name()+" : "+bean.getReply_content());
    }

    @Override
    public int getItemCount() {
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_recitem_postreply_content)
        TextView tvRecitemPostreplyContent;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
